home *** CD-ROM | disk | FTP | other *** search
- #include "stdio.h"
-
- void main()
- {
- FILE *infile;
- char c, infilename[25], inputline[100];
- int line = 1;
-
- printf("Enter input file name ----> ");
- scanf("%s", infilename);
- infile = fopen(infilename, "r");
-
- printf("%5d", line);
- do {
- c = fgets(inputline, 100, infile); /* read a line */
- if (c != NULL) {
- printf("%5d %s", line, inputline);
- line++;
- }
- } while (c != NULL);
-
- fclose(infile);
- }
-
-
-
- /* Result of execution
-
- (You will get a listing of the file on the monitor with line numbers)
-
- */
-